< previous page page_905 next page >

Page 905
The CreateScript Method
Now you're ready for the fun stuff. The next method is the one that actually creates the script. Add the code from Listing A.31 to the module.
Type.gifListing A.31. Coding the CreateScript subroutine.
Public Sub CreateScript()
    '
    ' walk through database objects and produce text file
    '
    On Error Resume Next
    '
    Dim objTableDef As TableDef
    Dim objIndex As Index
    Dim objRelation As Relation
    '
    ' add script header
    cWrLine = WrScriptHeader(cDBName)
    Print #nWrFile, cWrLine
    '
    ' add database create code
    cWrLine = WrCreateDB(cDBName)
    Print #nWrFile, cWrLine
    '
    ' add table create code
    For Each objTableDef In objDB.TableDefs
        cWrLine = WrCreateTable(objTableDef)
        If Len(cWrLine) > 0 Then
            Print #nWrFile, cWrLine
        End If
        '
        For Each objIndex In objTableDef.Indexes
            cWrLine = WrCreateIndex(objIndex, objTableDef.Name)
            If Len(cWrLine) > 0 Then
                Print #nWrFile, cWrLine
            End If
        Next
    Next
    '
    ' add relation create code
    For Each objRelation In objDB.Relations
        cWrLine = wrCreateRelation(objRelation)
        If Len(cWrLine) > 0 Then
            Print #nWrFile, cWrLine
        End If
    Next
    '
    ' add script footer
    cWrLine = WrScriptFooter
    Print #nWrFile, cWrLine
    '
    SQLVBMain.lblProgress = ""
End Sub

 
< previous page page_905 next page >

If you like this book, buy it!